<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>配件管理</title>
	<meta name="decorator" content="default"/>
	<style type="text/css">
	
	/*底部分页*/
			
			.button_ul a {
				float: left;
				margin-left: 20px;
				padding: 0 8px 0 8px;
				font-weight: bold;
				background: #F6F6FB;
				color: #3399CC;
				font-family: '黑体';
			}
			
			.button_ul .this_page {
				background: #CACACA;
			}
			
			.color:visited {
				color: #35B0EE;
				text-decoration: none;
				font-weight: bold;
			}
			
			.color:hover {
				text-decoration: underline;
			}
	
	</style>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#btnImportPic").click(function(){
				$.jBox($("#importPicBox").html(), {title:"导入数据", buttons:{"关闭":true}, 
					bottomText:"仅允许导入“zip”格式文件！"});
			});
			
			
			$("#btnImportElement").click(function(){
				$.jBox($("#importBox").html(), {title:"导入数据", buttons:{"关闭":true}, 
					bottomText:"导入文件不能超过5M，仅允许导入“xls”或“xlsx”格式文件！"});
			});
			
			$("#updateElementImport").click(function(){
				$.jBox($("#importElementBox").html(), {title:"导入数据", buttons:{"关闭":true}, 
					bottomText:"导入文件不能超过5M，仅允许导入“xls”或“xlsx”格式文件！"});
			});
			
			$("#checkAll").click(function() {        
				$('input[name="subBox"]').attr("checked",this.checked);       
			});
			var $subBox = $("input[name='subBox']");      
			$subBox.click(function(){        
				$("#checkAll").attr("checked",$subBox.length == $("input[name='subBox']:checked").length ? true : false);      
			});
			
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
		
		 function batchDeletes() {
				//判断至少写了一项
				var checkedNum = $("input[name='subBox']:checked").length;
				if (checkedNum == 0) {
					alert("请至少选择一项!");
					return false;
				}
				if (confirm("确定删除所选项目?")) {
					var checkedList = new Array();
					$("input[name='subBox']:checked").each(function() {
						checkedList.push($(this).val());
					});
					$.ajax({
						type : "POST",
						url : ctx+"/element/sfElement/batchDeletes",
						data : {
							"delitems" : checkedList.toString()
						},
						datatype : "html",
						success : function(data) {
							alert('删除成功!');
							setTimeout("location.reload()", 1000);//页面刷新
						},
						error : function(data) {
							alert('删除失败!');
						}
					});
				}
			}
		
	</script>
</head>
<body>
	<div id="importPicBox" class="hide">
		<form id="importPicForm" action="${ctx}/element/sfElement/importPic" method="post" enctype="multipart/form-data" 
		class="form-search" style="padding-left:20px;text-align:center;" onsubmit="loading('正在导入，请稍等...');"><br/>
			<input id="uploadPicFile" name="mfile" type="file" style="width:330px"/><br/><br/>　　
			<input id="btnImportPicSubmit" class="btn btn-primary" type="submit" value="   导    入   "/>
<%-- 			<a href="${ctx}/project/sfProject/import/template">下载模板</a> --%>
		</form>
	</div>
	<div id="importBox" class="hide">
		<form id="importForm" action="${ctx}/project/sfProject/importelement" method="post" enctype="multipart/form-data" 
		class="form-search" style="padding-left:20px;text-align:center;" onsubmit="loading('正在导入，请稍等...');"><br/>
			<input id="uploadFile" name="file" type="file" style="width:330px"/><br/><br/>　　
			<input id="btnImportSubmit" class="btn btn-primary" type="submit" value="   导    入   "/>
<%-- 			<a href="${ctx}/project/sfProject/import/template">下载模板</a> --%>
		</form>
	</div>
	
		<div id="importElementBox" class="hide">
		<form id="importElmentForm" action="${ctx}/element/sfElement/updateelementimport" method="post" enctype="multipart/form-data" 
		class="form-search" style="padding-left:20px;text-align:center;" onsubmit="loading('正在导入，请稍等...');"><br/>
			<input id="uploadElmentFile" name="file" type="file" style="width:330px"/><br/><br/>　　
			<input id="btnElmentImportSubmit" class="btn btn-primary" type="submit" value="   导    入   "/>
<%-- 			<a href="${ctx}/project/sfProject/import/template">下载模板</a> --%>
		</form>
	</div>
	
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/element/sfElement/">配件列表</a></li>
		<shiro:hasPermission name="element:sfElement:edit"><li><a href="${ctx}/element/sfElement/form">配件添加</a></li></shiro:hasPermission>
	</ul>
	<form:form id="searchForm" modelAttribute="sfElement" action="${ctx}/element/sfElement/" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<ul class="ul-form">
			<li class="btns">
				<input type="button" onclick="batchDeletes()" value="批量删除"  class="btn btn-primary">
			</li>
			<li class="clearfix"></li>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
			<th><input id="checkAll" type="checkbox"  /></th>
				<th>编码</th>
				<th>简介</th>
				<th>英文简介</th>
				<th>实际库存</th>
				<th>安全库存</th>
				<th>生产/采购周期</th>
				<th>配件属性</th>
				<th>图片存放</th>
				<shiro:hasPermission name="element:sfElement:edit"><th>操作</th></shiro:hasPermission>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${list}" var="sfElement">
			<tr>
			  <td><input name="subBox" type="checkbox" value="${sfElement.id}" /></td>
				<td><a href="${ctx}/element/sfElement/form?id=${sfElement.id}">
					${sfElement.code}
				</a></td>
				<td>
					${sfElement.content}
				</td>
				<td>
					${sfElement.enContent}
				</td>
				<td>
					${sfElement.num}
				</td>
				<td>
					${sfElement.safeNum}
				</td>
				<td>
					${sfElement.productionCycle}
				</td>
				<td>${sfElement.attributes }</td>
				<td>${sfElement.existImage }</td>
				<shiro:hasPermission name="element:sfElement:edit"><td>
    				<a href="${ctx}/element/sfElement/form?id=${sfElement.id}">修改</a>
					<a href="${ctx}/element/sfElement/delete?id=${sfElement.id}" onclick="return confirmx('确认要删除该配件吗？', this.href)">删除</a>
					
				</td></shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	
	
	
	  <!-- 底部操作 -->
			<br />
			<div  style="float: left;position: relative;left: 50%;width: 75%;">
				<ul class="button_ul" style="list-style: none;position: relative;left: -50%;width: 100%;">
					<li>
						<a class="color" href="${ctx}/element/sfElement/productelementlist?current=1&id=${sfProduct.id}&type=startPage&pid=${pid} ">首页</a>
					</li>
					<li>
						<c:if test="${current=='1'}">
							<a class="color" href="${ctx}/element/sfElement/productelementlist?current=1&id=${sfProduct.id}&type=hasPrePage&pid=${pid}">上一页</a>
						</c:if>
						<c:if test="${current!='1'}">
							<a class="color" href="${ctx}/element/sfElement/productelementlist?current=${current-1}&id=${sfProduct.id}&type=hasPrePage&pid=${pid}">上一页</a>
						</c:if>
					</li>

					<li >
						<a class="color" href="${ctx}/element/sfElement/productelementlist?current=${current+1}&id=${sfProduct.id}&type=hasNextPage&pid=${pid}">下一页</a>
					</li>
					<li >
						<a class="color" href="${ctx}/element/sfElement/productelementlist?current=1&id=${sfProduct.id}&type=endPage&pid=${pid}">末页</a>
					</li>
					<li>当前${current}/${tp}  </li>
					
				</ul>
			</div>  
</body>
</html>